<?php
require_once(__PHY_LIB.'/class/Item.class.php');
require_once(__PHY_LIB.'/class/uUser.class.php');

class uEnroll extends Item {
	/// definition and constructor ///
	function uEnroll($id=0, $field="") {
		Query::Query();
		$this->cfgKeyField("id");
		$this->cfgAllField("id,user_id,sign,gender,contact,email,photo_url,demo,description,work1_url,work2_url,work3_url,time_added,status");
		$this->cfgTable("unit_enroll");
		if ("" == $field || "*" == $field) {
			$this->cfgField($this->mAllField);
		}
		else {
			$this->cfgField($field);
		}
		if (0 < $id) {
			$this->cfgWhere($this->mKeyField . "=" . $id);
			$this->load();
		}
		else {
			$this->set($this->mKeyField, $id);
		}
	}

	function invalid() {
		return false;
	}

	function upgradeToArtist() {
		$oUser = new uUser($this->get('user_id'));
		$oUser->saveThumb(__PHY_STO.$this->get('photo_url'));
		$oUser->set('role_artist', 1);
		$oUser->set('sign', $this->get('sign'));
		$oUser->set('gender', $this->get('gender'));
		$oUser->set('demo', $this->get('demo'));
		$oUser->set('description', $this->get('description'));
		$oUser->set('description_en', $this->get('description'));
		$oUser->update();
	}

} /// end class uEnroll.

class uEnrollList extends ItemList {
	/// definition and constructor ///
	function uEnrollList($tablename=null) {
		ItemList::ItemList();
		$this->cfgClass("uEnroll");
		$this->cfgKeyField("id");
		$this->cfgAllField("id,user_id,sign,gender,contact,email,photo_url,demo,description,work1_url,work2_url,work3_url,time_added,status");
		$this->cfgTable(null == $tablename ? "unit_enroll" : $tablename);
	}

} /// end class uEnrollList.
?>
